import imgFilesFilter
import os
import subprocess
import shutil
from pathlib import Path
from typing import Dict, List
from util import gifToMp4


def main(base_path : str):
    # 获取要生成封面的视频
    file = imgFilesFilter.list_all_file_names(base_path)
    for index, fruit in enumerate(file):
        print(fruit)
        out_name = f"D:\\qycache\\download\\哆啦A梦 第5季\\output{index}_%03d.jpg"
        result = subprocess.run(
            [
                "ffmpeg",
                "-ss", "00:02:00",
                "-to", "00:10:00",
                "-i", fruit,
                "-vf", "fps=1/20,scale=1920:1080:force_original_aspect_ratio=decrease,pad=1920:1080:(ow-iw)/2:(oh-ih)/2,crop=min(iw\,1500):min(ih\,1080):0:0",
                out_name
            ],  # 命令参数以列表形式传递（更安全）
            capture_output=True,  # 捕获stdout和stderr
            text=True,  # 以文本形式返回（否则是bytes）
            shell=True,  # Windows需设为True，Linux/macOS通常不需要
            encoding="utf-8"  # 显式指定 UTF-8 编码
        )




if __name__ == "__main__":
    main(r"D:\qycache\download\哆啦A梦 第5季")
